import%20marimo%0A%0A__generated_with%20%3D%20%220.17.6%22%0Aapp%20%3D%20marimo.App(width%3D%22medium%22%2C%20auto_download%3D%5B%22html%22%2C%20%22ipynb%22%5D)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_()%3A%0A%20%20%20%20import%20pytz%0A%20%20%20%20import%20datetime%0A%20%20%20%20import%20marimo%20as%20mo%0A%0A%20%20%20%20india_timezone%20%3D%20pytz.timezone(%22Asia%2FKolkata%22)%0A%20%20%20%20now%20%3D%20datetime.datetime.now(india_timezone)%0A%0A%20%20%20%20curr%20%3D%20now.strftime(%22%25Y-%25m-%25d%2C%20%25I%3A%25M%3A%25S%20%25p%20%25Z%22)%0A%0A%20%20%20%20mo.md(%0A%20%20%20%20%20%20%20%20rf%22%22%22%0A%20%20%20%20%23%20Week%20-%209.2%0A%0A%20%20%20%20**Submission%20Date%3A**%20%60This%20assignment%20will%20not%20be%20graded%20and%20is%20only%20for%20practice.%60%0A%0A%20%20%20%20**Last%20Updated%3A**%20%60%7Bcurr%7D%60%0A%20%20%20%20%22%22%22%0A%20%20%20%20)%0A%20%20%20%20return%20(mo%2C)%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20import%20numpy%20as%20np%0A%20%20%20%20import%20pandas%20as%20pd%0A%20%20%20%20import%20matplotlib.pyplot%20as%20plt%0A%20%20%20%20import%20seaborn%20as%20sns%0A%20%20%20%20from%20sklearn.model_selection%20import%20train_test_split%0A%20%20%20%20from%20sklearn.neural_network%20import%20MLPClassifier%0A%20%20%20%20from%20sklearn.preprocessing%20import%20StandardScaler%0A%20%20%20%20from%20sklearn.pipeline%20import%20Pipeline%0A%20%20%20%20from%20sklearn.metrics%20import%20accuracy_score%0A%20%20%20%20return%20(%0A%20%20%20%20%20%20%20%20MLPClassifier%2C%0A%20%20%20%20%20%20%20%20Pipeline%2C%0A%20%20%20%20%20%20%20%20StandardScaler%2C%0A%20%20%20%20%20%20%20%20accuracy_score%2C%0A%20%20%20%20%20%20%20%20np%2C%0A%20%20%20%20%20%20%20%20pd%2C%0A%20%20%20%20%20%20%20%20sns%2C%0A%20%20%20%20%20%20%20%20train_test_split%2C%0A%20%20%20%20)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(%22%22%22%23%23%23%20About%20the%20dataset%3A%0A%0A%20%20%20%20This%20dataset%20is%20originally%20from%20the%20National%20Institute%20of%20Diabetes%20and%20Digestive%20and%20Kidney%20Diseases.%20The%20objective%20of%20the%20dataset%20is%20to%20diagnostically%20predict%20whether%20or%20not%20a%20patient%20has%20diabetes%2C%20based%20on%20certain%20diagnostic%20measurements%20included%20in%20the%20dataset.%0A%0A%20%20%20%20**Dataset%3A**%20%5C%22https%3A%2F%2Fdrive.google.com%2Ffile%2Fd%2F10Dj5jGYoqc7T5AMV_jBXJzDQQscHbrQ9%2Fview%3Fusp%3Dsharing%5C%22%22%22%22).callout()%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(pd)%3A%0A%20%20%20%20df%20%3D%20pd.read_csv(%0A%20%20%20%20%20%20%20%20%22https%3A%2F%2Fdrive.google.com%2Fuc%3Fid%3D10Dj5jGYoqc7T5AMV_jBXJzDQQscHbrQ9%26export%3Ddownload%22%0A%20%20%20%20)%0A%20%20%20%20return%20(df%2C)%0A%0A%0A%40app.cell%0Adef%20_(df)%3A%0A%20%20%20%20X%20%3D%20df.drop(columns%3D%22Outcome%22)%0A%20%20%20%20y%20%3D%20df%5B%22Outcome%22%5D%0A%20%20%20%20return%20X%2C%20y%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Instructions%20for%20questions%201%2C%202%20and%203%0A%0A%20%20%20%20Load%20the%20diabetes%20dataset.%0A%20%20%20%20Separate%20features%20and%20label.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%23%20Question%201%0A%0A%20%20%20%20Which%20of%20the%20following%20feature%20pairs%20have%20negative%20correlation%3F%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(X%2C%20sns)%3A%0A%20%20%20%20sns.heatmap(X.corr())%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%23%20Question%203%0A%0A%20%20%20%20Which%20of%20the%20following%20features%20has%20the%20highest%20standard%20deviation%3F%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(X%2C%20np)%3A%0A%20%20%20%20X.columns%5Bnp.array(%5BX%5Bi%5D.std()%20for%20i%20in%20X.columns%5D).argmax()%5D%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%23%20Question%204%0A%0A%20%20%20%20Is%20there%20any%20missing%20values%20in%20the%20dataset%3F%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(X)%3A%0A%20%20%20%20%22Yes%22%20if%20X.isna().sum().sum()%20else%20%22No%22%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Instructions%20for%20questions%204%20to%207%0A%0A%20%20%20%20split%20the%20dataset%20into%20training%20and%20test%20dataset%20in%20**80%3A20**%20proportion%20with%0A%0A%20%20%20%20%60%60%60%0A%20%20%20%20%22random_state%22%3A%201%0A%20%20%20%20%60%60%60%0A%0A%20%20%20%20Create%20a%20pipeline%20with%20scaler%20as%20StandardScaler%20and%20classifier%20as%20MLPClassifier.%0A%0A%20%20%20%20Classifier%20should%20have%20the%20following%20properties%3A%0A%0A%20%20%20%20-%20Classifier%20should%20have%20three%20hidden%20layers%20with%2010%20neurons%20each.%0A%20%20%20%20-%20Set%0A%20%20%20%20%20%20%20%20%60%60%60%0A%20%20%20%20%20%20%20%20activation%3D'relu'%2C%20solver%3D'sgd'%2C%20alpha%3D%201e-4%2C%20learning_rate_init%3D%200.2%20%2Cmax_iter%3D500%2C%20random_state%3D1%0A%20%20%20%20%20%20%20%20%60%60%60%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(X%2C%20train_test_split%2C%20y)%3A%0A%20%20%20%20X_train%2C%20X_test%2C%20y_train%2C%20y_test%20%3D%20train_test_split(%0A%20%20%20%20%20%20%20%20X%2C%20y%2C%20test_size%3D0.2%2C%20random_state%3D1%0A%20%20%20%20)%0A%20%20%20%20return%20X_test%2C%20X_train%2C%20y_test%2C%20y_train%0A%0A%0A%40app.cell%0Adef%20_(MLPClassifier%2C%20Pipeline%2C%20StandardScaler)%3A%0A%20%20%20%20pipeline%20%3D%20Pipeline(%0A%20%20%20%20%20%20%20%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20(%22scalar%22%2C%20StandardScaler())%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%22model%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20MLPClassifier(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20hidden_layer_sizes%3D(10%2C%2010%2C%2010)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20activation%3D%22relu%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20solver%3D%22sgd%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20alpha%3D1e-4%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20learning_rate_init%3D0.2%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20max_iter%3D500%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20random_state%3D1%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20)%0A%20%20%20%20return%20(pipeline%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%23%20Question%204%0A%0A%20%20%20%20What%20will%20be%20the%20mean%20accuracy%20of%20the%20model%20on%20the%20training%20data%3F%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(X_train%2C%20accuracy_score%2C%20pipeline%2C%20y_train)%3A%0A%20%20%20%20pipeline.fit(X_train%2C%20y_train)%0A%20%20%20%20accuracy_score(y_train%2C%20pipeline.predict(X_train))%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%23%20Question%205%0A%0A%20%20%20%20What%20will%20be%20the%20mean%20accuracy%20of%20the%20model%20on%20the%20test%20data%3F%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(X_test%2C%20accuracy_score%2C%20pipeline%2C%20y_test)%3A%0A%20%20%20%20accuracy_score(y_test%2C%20pipeline.predict(X_test))%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%23%20Question%206%0A%0A%20%20%20%20What%20is%20the%20output%20activation%20function%20used%20by%20the%20classifier%3F%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(pipeline)%3A%0A%20%20%20%20pipeline.named_steps%5B%22model%22%5D.out_activation_%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%23%20Question%207%0A%0A%20%20%20%20How%20many%20weights%20(excluding%20intercepts)%20between%20input%20layer%20and%20first%20hidden%20layer%20were%20learnt%20by%20the%20classifier%3F%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(X_train%2C%20pipeline)%3A%0A%20%20%20%20X_train.shape%5B1%5D%20*%20pipeline.named_steps%5B%22model%22%5D.hidden_layer_sizes%5B0%5D%0A%20%20%20%20return%0A%0A%0Aif%20__name__%20%3D%3D%20%22__main__%22%3A%0A%20%20%20%20app.run()%0A
7ec0fce410a41523eeb55637ab928bdb008fce326f6dfaf1f33fd5594acd2b5a